package com.jmyd.commons.base.vo;

import com.alibaba.fastjson.JSON;
import lombok.Data;

import java.io.Serializable;

/**
 * mtool 调用统一返回对象
 *
 * @author samphin
 * @date 2020-12-17 10:27:37
 */
@Data
public class GoResult implements Serializable {
    private static final long serialVersionUID = -2824594993801309102L;
    /**
     * 状态码
     */
    private boolean code = false;
    /**
     * 消息
     */
    private String error = "操作成功";

    public static String toString(boolean code) {
        GoResult result = new GoResult();
        result.setCode(code);
        return JSON.toJSONString(result);
    }

    public static String toString(boolean code, String message) {
        GoResult result = new GoResult();
        result.setError(message);
        result.setCode(code);
        return JSON.toJSONString(result);
    }

}
